/*--------------------------------------
f(1) = k

f(2) = f(1) + 1

f(3) = f(2) + 1 + 2

......

f(n) = f(n-1) + (1 + 2 + ... + n-1)
--------------------------------------*/
#include<stdio.h>
int figure(int x, int y);
int main()
{
    int n, a, b;
    scanf("%d", &n);

    for(int i = 0; i < n; i ++)
    {
        scanf("%d %d", &a, &b);
        int rst = figure(a, b);
        printf("%d\n", rst);
    }
    
    return 0;
}

int figure(int x, int y)
{
    if (x == 1)
    {
        return y;
    }
    else 
    {
        return figure(x - 1, y) + (x * (x - 1) / 2);
    }
}
